<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script src="./vue.js"></script>
    <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script>
</head>
<!-- 注意：引入时v-resource必须放在vue后面，因为v-resource是基于vue的
    jsonp请求没有实现，有bug是跨域的问题，暂未解决 -->

<body>
    <div id="a">
        <input type="button" value="get 请求" @click="get">
        <input type="button" value="post请求" @click='post'>
        <input type="button" value="jsonp请求" @click='jsonp'>
    </div>

    <script>
        new Vue({
            el: '#a',
            data: {},
            methods: {
                get: function() {
                    this.$http.get("https://autumnfish.cn/api/joke/list").then(response => {
                        console.log(response);
                    });
                },
                post: function() {
                    this.$http.post('https://autumnfish.cn/api/user/reg').then(response => {
                        console.log(response);
                    })
                },
                jsonp: function() {
                    this.$http.jsonp('http://vue.studyit.io/api/jsonp').then(response => {
                        console.log(response);
                    })
                }
            }
        })
    </script>
</body>

</html>